home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / sjpege.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.4 KB  |  119 lines

  1. /* Copyright (C) 1994, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: sjpege.c,v 1.2 2000/09/19 19:00:50 lpd Exp $ */
  20. /* Interface routines for IJG encoding code. */
  21. #include "stdio_.h"
  22. #include "string_.h"
  23. #include "jpeglib_.h"
  24. #include "jerror_.h"
  25. #include "gx.h"
  26. #include "gserrors.h"
  27. #include "strimpl.h"
  28. #include "sdct.h"
  29. #include "sjpeg.h"
  30.  
  31. /*
  32.  * Interface routines.  This layer of routines exists solely to limit
  33.  * side-effects from using setjmp.
  34.  */
  35.  
  36. int
  37. gs_jpeg_create_compress(stream_DCT_state * st)
  38. {                /* Initialize error handling */
  39.     gs_jpeg_error_setup(st);
  40.     /* Establish the setjmp return context for gs_jpeg_error_exit to use. */
  41.     if (setjmp(st->data.common->exit_jmpbuf))
  42.     return_error(gs_jpeg_log_error(st));
  43.  
  44.     jpeg_create_compress(&st->data.compress->cinfo);
  45.     jpeg_stream_data_common_init(st->data.compress);
  46.     return 0;
  47. }
  48.  
  49. int
  50. gs_jpeg_set_defaults(stream_DCT_state * st)
  51. {
  52.     if (setjmp(st->data.common->exit_jmpbuf))
  53.     return_error(gs_jpeg_log_error(st));
  54.     jpeg_set_defaults(&st->data.compress->cinfo);
  55.     return 0;
  56. }
  57.  
  58. int
  59. gs_jpeg_set_colorspace(stream_DCT_state * st,
  60.                J_COLOR_SPACE colorspace)
  61. {
  62.     if (setjmp(st->data.common->exit_jmpbuf))
  63.     return_error(gs_jpeg_log_error(st));
  64.     jpeg_set_colorspace(&st->data.compress->cinfo, colorspace);
  65.     return 0;
  66. }
  67.  
  68. int
  69. gs_jpeg_set_linear_quality(stream_DCT_state * st,
  70.                int scale_factor, boolean force_baseline)
  71. {
  72.     if (setjmp(st->data.common->exit_jmpbuf))
  73.     return_error(gs_jpeg_log_error(st));
  74.     jpeg_set_linear_quality(&st->data.compress->cinfo,
  75.                 scale_factor, force_baseline);
  76.     return 0;
  77. }
  78.  
  79. int
  80. gs_jpeg_set_quality(stream_DCT_state * st,
  81.             int quality, boolean force_baseline)
  82. {
  83.     if (setjmp(st->data.common->exit_jmpbuf))
  84.     return_error(gs_jpeg_log_error(st));
  85.     jpeg_set_quality(&st->data.compress->cinfo,
  86.              quality, force_baseline);
  87.     return 0;
  88. }
  89.  
  90. int
  91. gs_jpeg_start_compress(stream_DCT_state * st,
  92.                boolean write_all_tables)
  93. {
  94.     if (setjmp(st->data.common->exit_jmpbuf))
  95.     return_error(gs_jpeg_log_error(st));
  96.     jpeg_start_compress(&st->data.compress->cinfo, write_all_tables);
  97.     return 0;
  98. }
  99.  
  100. int
  101. gs_jpeg_write_scanlines(stream_DCT_state * st,
  102.             JSAMPARRAY scanlines,
  103.             int num_lines)
  104. {
  105.     if (setjmp(st->data.common->exit_jmpbuf))
  106.     return_error(gs_jpeg_log_error(st));
  107.     return (int)jpeg_write_scanlines(&st->data.compress->cinfo,
  108.                      scanlines, (JDIMENSION) num_lines);
  109. }
  110.  
  111. int
  112. gs_jpeg_finish_compress(stream_DCT_state * st)
  113. {
  114.     if (setjmp(st->data.common->exit_jmpbuf))
  115.     return_error(gs_jpeg_log_error(st));
  116.     jpeg_finish_compress(&st->data.compress->cinfo);
  117.     return 0;
  118. }
  119.